<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCategoriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('categories', function (Blueprint $table) {
            $table->increments('id')->unsigned();
            $table->integer('parent_id')->unsigned()->nullable()->default(null);
            $table->string('name',50)->comment('分类名称');
            $table->unsignedInteger('hot')->comment('分类热度');
            $table->string('image')->comment('分类图片');
            $table->timestamps();
        });
        $driverName = Schema::getConnection()->getDriverName();
        if ('mysql' === $driverName) {
            DB::update(<<<END
                ALTER TABLE `comment`
                ENGINE=InnoDB,
                DEFAULT CHARACTER SET=utf8,
                AUTO_INCREMENT=100;
END
            );
        }
    }


    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('categories');
    }
}
